package com.franz.noteapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.navigation.compose.rememberNavController
import com.franz.noteapp.nav.NavigationGraph
import com.franz.noteapp.ui.theme.NoteAppTheme
import com.franz.noteapp.ui.theme.NoteTheme
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.insets.navigationBarsPadding
import com.google.accompanist.insets.statusBarsPadding
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        WindowCompat.setDecorFitsSystemWindows(window,false)
        installSplashScreen()
        super.onCreate(savedInstanceState)
        setContent {
            NoteAppTheme {
                ProvideWindowInsets() {
                    val systemUiController = rememberSystemUiController()
                    SideEffect {
                        systemUiController.setStatusBarColor(Color.Transparent, darkIcons = false)
                    }
                    Surface(
                        color = NoteTheme.colors.background,
                        modifier = Modifier.fillMaxSize().navigationBarsPadding()
                    ) {
                        val navHostController = rememberNavController()
                        NavigationGraph(navHostController = navHostController)
                    }
                }
            }
        }
    }
}
